

#import "UIImage+Category.h"
//#import "GPUImage.h"


@implementation UIImage (Category)

/**
 * 将UIColor变换为UIImage
 **/
+ (UIImage *)createImageWithColor:(UIColor *)color
{
    CGRect rect = CGRectMake(0.0f, 0.0f, 1.0f, 1.0f);
    UIGraphicsBeginImageContext(rect.size);
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextSetFillColorWithColor(context, [color CGColor]);
    CGContextFillRect(context, rect);
    UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    
    
    return theImage;
}

/**
 
 * 创建纯色的图片，用来做背景
 
 */

+ (UIImage *)switchToImageWithColor:(UIColor *)color size:(CGSize)size

{
    
    UIGraphicsBeginImageContextWithOptions(size, 0, [UIScreen mainScreen].scale);
    
    [color set];
    
    UIRectFill(CGRectMake(0, 0, size.width, size.height));
    
    UIImage *ColorImg = UIGraphicsGetImageFromCurrentImageContext();
    
    UIGraphicsEndImageContext();
    
    return ColorImg;
    
}

//+ (UIImage *)blurImage:(UIImage *)image floatBlurLevel:(CGFloat)level
//{
//    UIImage * resultImage;
//    if(image){
//        GPUImageGaussianBlurFilter * blurFilter = [[GPUImageGaussianBlurFilter alloc] init];
//        blurFilter.blurRadiusInPixels = level;
//        resultImage = [blurFilter imageByFilteringImage:image];
//    }
//    return resultImage?resultImage:image;
//}

@end
